package com.edu.exam.enums;

/**
 * 确认状态枚举
 * 
 * @author S-01 Module Designer
 * @version 2.0
 * @since 2025-11-10
 */
public enum ConfirmationStatus {
    PENDING("pending", "待确认"),
    APPROVED("approved", "已批准"),
    REJECTED("rejected", "已拒绝"),
    CANCELLED("cancelled", "已取消"),
    EXPIRED("expired", "已过期");

    private final String code;
    private final String description;

    ConfirmationStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 获取中文显示名称
     * 
     * @return 中文显示名称
     */
    @Override
    public String toString() {
        return code + " - " + description;
    }

    public static ConfirmationStatus fromCode(String code) {
        for (ConfirmationStatus status : ConfirmationStatus.values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown confirmation status code: " + code);
    }

    public static ConfirmationStatus fromDescription(String description) {
        for (ConfirmationStatus status : ConfirmationStatus.values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown confirmation status description: " + description);
    }
}